package com.net.shard;

import com.net.shard.domain.ShardConfig;

/**
 * Created by  on 2016/1/18.
 */
public class ShardUtil {
    public static void setShardContext(ShardConfig shardConfig) {
        ShardContext shardContext = new ShardContext();
        shardContext.setShardId(shardConfig.getShardId());
        ShardContextHolder.putShardContext(shardContext);  //!important:设置好分库的上下文
    }



    public static void setShardContext(Long shardId) {
        ShardContext context = new ShardContext();
        context.setShardId(shardId);
        ShardContextHolder.putShardContext(context);  //!important:设置好分库的上下文
    }

    public static void cleanShardContext() {
        ShardContextHolder.removeShardContext();  //!important:清除掉分库的上下文
    }
}
